package cn.sunchis.demo;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.gftech.framework.api.ResponseCode;
import com.gftech.framework.api.UnifyResponse;
import com.gftech.framework.util.DateTimeUtils;

/**
 * Nacos Client
 * @Author 许亮
 * @Create 2019-12-25 11:10:08
 */
@RefreshScope
@RestController
@EnableDiscoveryClient
@SpringBootApplication
public class NacosProviderApplication {
	@Value("${spring.application.use-local-cache:false}")
	private boolean useLocalCache;
	
	public static void main(String[] args) {
		SpringApplication.run(NacosProviderApplication.class, args);
	}
	
	@GetMapping("/prop")
	public UnifyResponse<?> prop() {
		return new UnifyResponse<>(ResponseCode.SUCCESS, useLocalCache);
	}
	
	@GetMapping("/now")
	public UnifyResponse<?> now() {
		return new UnifyResponse<>(ResponseCode.SUCCESS, DateTimeUtils.dateToStr(null, "yyyy-MM-dd HH:mm:ss"));
	}
}
